﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Expertise.aspx.cs" Inherits="WEB.APP.Modules.System.Expertise" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<%@ Register Src="~/Controls/System/ExpertiseForm.ascx" TagName="WindowEditor" TagPrefix="uc" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <title></title>
    <script language="javascript" type="text/javascript">
        function AlterEdit(el) {
            MethodNamespace.QuickEdit(el.record.data.ExpertiseId, el.record.data.Name,
            {
                success: function () {
                    stMain.commitChanges();
                }
            });
        }

        var startEditing = function (e) {
            if (e.getKey() === e.ENTER || e.getKey() === e.SPACE) {
                var record = grdMain.getSelectionModel().getSelected(),
                    index = grdMain.store.indexOf(record);
                var clIndex = grdMain.colModel.getIndexById('Name');
                StartEdit_Grid(grdMain, index, clIndex);
            }
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <ext:Hidden runat="server" ID="hfIsEdit" />
    <ext:Hidden runat="server" ID="Hidden1" />
    <ext:Store runat="server" ID="stMain" OnRefreshData="stMain_OnRefreshData">
        <Proxy>
            <ext:PageProxy />
        </Proxy>
        <Reader>
            <ext:JsonReader IDProperty="ExpertiseId">
                <Fields>
                    <ext:RecordField Name="ExpertiseId" />
                    <ext:RecordField Name="Name" />
                </Fields>
            </ext:JsonReader>
        </Reader>
    </ext:Store>
    <ext:Hidden runat="server" ID="hfIsDelete" Text="" />
    <ext:Viewport ID="ViewPort1" runat="server" Layout="RowLayout">
        <Items>
            <ext:GridPanel ID="grdMain" runat="server" Border="false" RowHeight="1" StoreID="stMain"
                EnableColumnHide="False" EnableColumnMove="False">
                <TopBar>
                    <ext:Toolbar ID="Toolbar1" runat="server" LabelWidth="55">
                        <Items>
                            <ext:Button ID="btnAdd" runat="server" Icon="CommentAdd" Text="New">
                                <DirectEvents>
                                    <Click OnEvent="btnNew_Click" />
                                </DirectEvents>
                            </ext:Button>
                            <ext:ToolbarSeparator runat="server" ID="tbs1" />
                            <ext:Button ID="btnDelete" runat="server" Icon="CommentDelete" Text="Delete">
                                <Listeners>
                                    <Click Handler="deleteRows(#{grdMain});" />
                                </Listeners>
                            </ext:Button>
                            <ext:ToolbarSeparator runat="server" ID="tbs2" />
                        </Items>
                    </ext:Toolbar>
                </TopBar>
                <ColumnModel ID="ColumnModel1" runat="server">
                    <Columns>
                        <ext:RowNumbererColumn />
                        <ext:Column ColumnID="Name" DataIndex="Name" Header="Expertise" Width="200">
                            <Editor>
                                <ext:TextField ID="TextField1" runat="server" SelectOnFocus="true" MinValue="0" />
                            </Editor>
                        </ext:Column>
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel ID="RowSelectionModel1" SingleSelect="false" runat="server">
                    </ext:RowSelectionModel>
                </SelectionModel>
                <KeyMap>
                    <ext:KeyBinding>
                        <Keys>
                            <ext:Key Code="DELETE" />
                        </Keys>
                        <Listeners>
                            <Event Handler="deleteRows(#{grdMain});" />
                        </Listeners>
                    </ext:KeyBinding>
                </KeyMap>
                <KeyMap>
                    <ext:KeyBinding>
                        <Keys>
                            <ext:Key Code="ESC" />
                        </Keys>
                        <Listeners>
                            <Event Handler="KeyPress_ESC(grdMain)" />
                        </Listeners>
                    </ext:KeyBinding>
                </KeyMap>
                <Listeners>
                    <KeyDown Fn="startEditing" />
                    <AfterEdit Fn="AlterEdit" />
                    <%--<RowDblClick Handler="this.getSelectionModel().selectRow(rowIndex); viewWinDetail(#{grdMain});" />--%>
                    <RowContextMenu Handler="e.preventDefault(); #{RowContextMenu}.dataRecord = this.store.getAt(rowIndex); #{RowContextMenu}.showAt(e.getXY()); if(grdMain.selModel.selections.items.length>1) {#{mnEdit}.disable();} else {#{mnEdit}.enable();this.getSelectionModel().selectRow(rowIndex);}" />
                </Listeners>
                <LoadMask ShowMask="true" />
            </ext:GridPanel>
        </Items>
    </ext:Viewport>
    <uc:WindowEditor ID="WindowEditor" runat="server" />
    <ext:Menu ID="RowContextMenu" runat="server">
        <Items>
            <ext:MenuItem ID="mnEdit" runat="server" Text="Edit" Icon="TableEdit">
                <Listeners>
                    <Click Handler="viewWinDetail(#{grdMain});" />
                </Listeners>
            </ext:MenuItem>
            <ext:MenuItem ID="mnDelete" runat="server" Text="Delete" Icon="Delete">
                <Listeners>
                    <Click Handler="deleteRows(#{grdMain});" />
                </Listeners>
            </ext:MenuItem>
        </Items>
    </ext:Menu>
    </form>
</body>
</html>
